<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:73:"D:\phpStudy\WWW\oa\public/../application/admin\view\region\regionadd.html";i:1512969115;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>添加主体</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 主体信息</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <div style="width: auto; height: auto;text-align: center">
        <form class="layui-form">
            <div style="margin-top: 2%;margin-bottom: 2%" class="layui-form-item">
                <div style="padding-left: 1%" class="layui-inline">
                    <label style="float: left;margin-top: 3%" class="layui-form-lable">主体：</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" lay-verify="required" type="text" name="region" id="region">
                    </div>
                </div>
            </div>
            <div style="margin-top: 2%;margin-bottom: 2%" class="layui-form-item">
                <div style="padding-right: 1.5%" class="layui-inline">
                    <label style="float: left;margin-top: 3%" class="layui-form-lable">联系电话：</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" lay-verify="required|number" type="text" name="number"
                               id="number">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label style="float: left;margin-top: 3%" class="layui-form-lable">负责人：</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" lay-verify="required" type="text" name="ch_name" id="ch_name">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" name="submit" lay-submit="" lay-filter="demo">立即添加
                    </button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer;
        //监听提交
        form.on('submit(demo)', function (datas) {
            var data = JSON.stringify(datas.field);
            var sub = 'submit';
            //alert(data);
            //layer.msg('11')
            $.ajax({
                url: "<?php echo url('Region/regionadd_sub'); ?>",
                type: "post",
                data: {'data': data, 'sub': sub},
                dataType: "json",
                success: function (aa) {
                    // console.log(aa);
                    if (aa == 1) {
                        layer.msg('添加成功');
                        window.setTimeout("window.location=\"<?php echo url('Region/admin'); ?>\"", 2000);

                    } else if (aa == 2) {
                        layer.msg('主体已添加，负责人未添加成功');
                        window.setTimeout("window.location=\"<?php echo url('Region/admin'); ?>\"", 2000);
                    } else if (aa == 3) {
                        layer.msg('主体名已被使用')
                    } else {
                        layer.msg('添加失败')
                    }
                }
            });
            return false;
        });
        form.verify({
            number: [/^([0-9]{3,4}-)?[0-9]{7,8}$/, '请输入正确的座机号码']
        });
    });
</script>
</html>